import time

from selenium.webdriver.common.by import By
from pom.base_page import BasePage


class LogManagePage(BasePage):
    def user_log(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[10]/li/ul/div[1]/a/li').click()
        time.sleep(2)
        # 跳转到最后一页
        self.driver.find_element(By.XPATH, '//div[2]/div/div[2]/section/div/div[3]/div/ul/li[8]').click()
        time.sleep(2)

        address = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]/section/div/form/div[1]/label').text
        user_name = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]/section/div/form/div[2]/label').text
        status = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]/section/div/form/div[3]/label').text
        login_time = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]/section/div/form/div[4]/label').text
        print(address, user_name, status, login_time, "*************")

        assert address == "登录地址"
        assert user_name == "用户名称"
        assert status == "状态"
        assert login_time == "登录时间"

    def os_log(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[10]/li/ul/div[2]/a/li').click()

        time.sleep(2)
        log_num = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[2]/div').text
        os_module = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        operation_type = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        print(log_num, os_module, operation_type, "****************")

        assert log_num == "2180"
        assert os_module == "日志"
        assert operation_type == "导出"

    def service_log(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[10]/li/ul/div[3]/a/li').click()

        time.sleep(2)
        num = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[2]/div').text
        service = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        sponsor = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        print(num, service, sponsor)

        assert num == "6186"
        assert service == "根据企业名称模糊查询企业联系人基本信息（通）"
        assert sponsor == "系统"

    def user_benefits(self):
        pass
